<?php echo $header;echo $sidebar ?>		

<link rel="stylesheet" href="<?php echo base_url(); ?>/assets/admin/css/new_font-awesome.css"/>
<link href="<?php echo $this->config->base_url(); ?>assets/admin/css/jquery-ui.css" rel="stylesheet">
	<link href="<?php echo $this->config->base_url(); ?>assets/admin/css/chosen.css" rel="stylesheet">
	<link href="<?php echo $this->config->base_url(); ?>assets/admin/css/chosen-bootstrap.css" rel="stylesheet">
	<script type="text/javascript" src="<?php echo $this->config->base_url(); ?>assets/admin/js/chosen.jquery.js"></script>
	<script type="text/javascript" src="<?php echo $this->config->base_url(); ?>assets/admin/js/jquery-ui.js"></script>
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/media/js/jquery.dataTables.columnFilter.js" type="text/javascript"></script>
	<style>
	select {background-color: #FFFFFF;border: 1px solid #CCCCCC;width: 200px !important;}
	.clear{clear: both;}
	</style>
	<div class="span10 content">

		<?php echo $hugemenu ?>

		<h1>Departments</h1>

		<?php if($this->session->flashdata('message')) :?>
			<div class="alert alert-success">
				<?php echo $this->session->flashdata('message') ?>
			</div>
		<?php endif; ?>
		
		<?php if($success_message) { echo "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $success_message . "</div>"; } ?>
		<?php if($message) { echo "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $message . "</div>"; } ?>
		

		<div class="row" style="padding:15px;">
			<div class="col-lg-12">
				<?php 
		        $error = $this->session->flashdata('error');
		            	
		        if($error)
		        {
		        	echo "<div class='alert alert-danger'>{$error}</div>";
		        } ?>
		        
				<?php  
				if($departments)
				{ ?>
					<table class="table table-striped table-bordered table-hover datatables">
						<thead>
							<tr>
								<th>Name</th>
								<th>Users</th>
								<th>Projects</th>
								<th class="hidden-xs">Status</th>
							</tr>
						</thead>
						<tbody>
							<?php 
					  		for($i = 0; $i < count($departments); ++$i)
					  		{ ?>
								<tr>
							      	<td><a href="<?php echo base_url(); ?>index.php/departments/view/<?php echo $departments[$i]['department_id']; ?>"><?php echo $departments[$i]['department_name']; ?></a></td>
							      	<td><?php echo $departments[$i]['department_num_users']; ?></td>
							      	<td><?php echo $departments[$i]['department_num_projects']; ?></td>
							      	<td class="hidden-xs">
							      		<?php 
							      		$status = $departments[$i]['department_is_active'];
							      		
							      		if($status)
							      		{
							      			echo "<span class='label label-success'>Active<span>";
							      		}
							      		else
							      		{
							      			echo "<span class='label label-danger'>Deactive<span>";
							      		} ?>
							      	</td>
								</tr>
							<?php 
					  		} ?>
						</tbody>
					</table>
				<?php 
				} 
				else
				{ ?>
					<p>Your company does not have any departments.</p>
				<?php 
				} ?>
			</div>
			
			
			<?php if($this->session->userdata('level')) { ?>
			<div style="margin-top: 20px;">
			<a href="<?php echo base_url(); ?>index.php/departments/create"><button type="button" class="btn btn-primary pull-left">New</button></a>
			</div>
			<div class="clear"></div>
			<?php } ?>
		</div>
		
		
	</div><!--/content-->
	
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/jquery-ui-1.10.2.custom.min.js"></script> <!-- jQuery UI -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/sparklines.js"></script>
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/fullcalendar.min.js"></script> <!-- Full Google Calendar - Calendar -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/bootstrap-datetimepicker.min.js"></script> <!-- Date picker -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/DT_bootstrap.js"></script> <!-- jQuery UI -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/jquery.prettyPhoto.js"></script> <!-- prettyPhoto -->
<?php echo $footer ?>